fix: repair failing tests and type errors across api and shared packages - #107
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#107stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- implement paginate stub in shared/utils per test contract - align User type field username (was userName) with tests and routes - add missing badRequest import in users route - fix auth middleware method-casing allowlist so POST /users is public - add bun-types to tsconfig types to resolve bun:test and process type errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing tests (now 22 pass / 0 fail) and eliminates all type errors (
tsc --noEmitclean) across theapiandsharedpackages. Each fix targets the root cause rather than papering over the symptom.Root causes fixed
packages/shared/src/utils/pagination.tspaginatestub per the test contract (data slice, total, totalPages, page, pageSize; empty array → totalPages 0; 1-indexed pages).packages/shared/src/types.tsUser.userName→usernameto match the spelling used by tests and route handlers.packages/api/src/routes/users.tsbadRequestimport from../lib/errors(was a runtimeReferenceError).packages/api/src/middleware/auth.ts"post"butc.req.methodis uppercase, soPOST /userswas wrongly rejected. Now["GET", "POST"].tsconfig.json"types": ["bun-types"](already installed) to resolveCannot find module 'bun:test'andCannot find name 'process'.Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ 0 errorsAssumptions & scope
username(lowercase) because tests and existing route code already use that spelling; the shared type was the sole outlier.totalPages: 0(no clamping to 1). Input guards for out-of-contract values (negative page, size 0/NaN) were intentionally not added — no route currently callspaginate, the tests don't exercise those inputs, and the constraint was to fix only what tests require. Noted here as a latent hardening opportunity for whoever first wires?page=/?size=into a route.Pre-existing, out-of-scope (untouched, noted for awareness)
auth.tsuses a hardcoded token fallback and a non-constant-time comparison — acceptable in this test corpus, not introduced or modified by this change.